package com.itheima.controller.user;


import com.itheima.common.entity.Result;
import com.itheima.common.utils.AliOssUtil;
import com.itheima.pojo.Setmeal;
import com.itheima.service.UserSetmealService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import java.util.List;

/**
 * 用户端套餐管理
 */
@RestController("userSetmealController")
@RequestMapping("/setmeal")
@Slf4j
public class SetmealController {
    @Autowired
    private UserSetmealService userSetmealService;
    @Autowired
    private AliOssUtil aliOssUtil;

    /**
     * 套餐全部查询
     * @return
     */
    @PostMapping("getSetmeal")
    public Result<List<Setmeal>> getAllSetmeal(){
       List<Setmeal> setmealList= userSetmealService.findAll();
       return Result.success(setmealList,"查询套餐数据成功");
    }

    /**
     * 根据套餐id查询套餐详情
     * @param id
     * @return
     */
    @PostMapping("findById")
    public Result<Setmeal> findById(@RequestParam String id){
       Setmeal setmeal = userSetmealService.findById(id);
      return Result.success(setmeal,"查询套餐数据成功");
    }


}
